public class InitializeRuggedArrayColumnWise{
  public static void main(String[] args){
      double[][] x = new double[5][];
      x[0] = new double[2];
      x[1] = new double[4];
      x[2] = new double[1];
      x[3] = new double[3];
      x[4] = new double[2];
    
      int c=0,r=0, count = 0;
       int k = 0;
      // Initialize rugged 2D array column-wise
      for(c = 0; c < 4; c++){    // 4 is the max number of columns
        System.out.printf("Column %d: ",k++);
        for(r = 0; r < x.length; r++){
           if(c < x[r].length){  // if c is a valid column for the current row
              x[r][c] = count++;
              System.out.print(x[r][c]+ " ");
           }
        }
        System.out.println();
      }
   }
}